package com.company.cloud.company.modules.app.controller;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.company.cloud.common.bean.BaseResult;
import com.company.cloud.common.constant.BaseConstant;
import com.company.cloud.common.utils.HttpContextUtils;
import com.company.cloud.common.utils.SpringContextUtils;
import com.company.cloud.common.utils.StrSplitUtils;
import com.company.cloud.company.constant.CompanyConstant;
import com.company.cloud.company.modules.api.request.CompanyQueryRequest;
import com.company.cloud.company.modules.api.response.CompanyFull;
import com.company.cloud.company.modules.app.controller.req.CompanyQuery4PageParam;
import com.company.cloud.company.modules.app.controller.req.TenantApplyParam;
import com.company.cloud.company.modules.base.entity.TenantApplyInfo;
import com.company.cloud.company.modules.base.service.TenantApplyInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

@Log4j2
@RestController
@RequestMapping("/app/user/companyApply")
@Api(tags="Company_App_公司申请")
public class TenantApplyController {

    @Autowired
    private TenantApplyInfoService tenantApplyInfoService;

    @PostMapping("/apply")
    @ApiOperation(value="公司申请", response= BaseResult.class)
    public BaseResult apply(@RequestBody TenantApplyParam params) {

        String ip = HttpContextUtils.getClientIP();
        TenantApplyInfo entity=new TenantApplyInfo();
        entity.setId(IdUtil.getSnowflake(3,3).nextIdStr());
        entity.setName(params.getName());
        entity.setType(params.getType());
        entity.setCompanyBizName(params.getCompanyBizName());
        entity.setCompanyBizCode(params.getCompanyBizCode());
        entity.setLinkName(params.getLinkName());
        entity.setLinkTel(params.getLinkTel());
        entity.setLinkMail(params.getLinkMail());
        entity.setCompanyBizImg(StrSplitUtils.list2string(params.getCompanyBizImg()));
        entity.setCompanyLegalIdImg(StrSplitUtils.list2string(params.getCompanyLegalIdImg()));
        entity.setCompanyBankImg(StrSplitUtils.list2string(params.getCompanyBankImg()));
        entity.setIdentity(params.getIdentity());
        entity.setWechat(params.getWechat());
        entity.setWorkType(params.getWorkType());
        entity.setWorkPhone(params.getWorkPhone());
        entity.setWorkWechat(params.getWorkWechat());
        entity.setWorkLegalIdImg(StrSplitUtils.list2string(params.getWorkLegalIdImg()));
        entity.setState(BaseConstant.YNEnum.NO.getCode());
        entity.setRowsState(BaseConstant.EnabledEnum.ENABLED.getCode());
        entity.setCman("1");
        entity.setCdt(LocalDateTime.now());
        entity.setCip(ip);
        entity.setEman("1");
        entity.setEdt(LocalDateTime.now());
        entity.setEip(ip);
        entity.setManagementRole(params.getManagementRole());
        entity.setStoreType(params.getStoreType());
        entity.setMainCategories(params.getMainCategories());
        entity.setCorePerson(params.getCorePerson());
        entity.setMentoringRelationship(params.getMentoringRelationship());
        entity.setEducationBackground(params.getEducationBackground());
        entity.setEducationBackground(params.getEducationBackground());
        entity.setWorkUnit(params.getWorkUnit());
        entity.setYearsOfWorking(params.getYearsOfWorking());
        entity.setRelevantExperience(params.getRelevantExperience());
        entity.setStudioImg(StrSplitUtils.list2string(params.getStudioImg()));
        entity.setProfessionalTitle(params.getProfessionalTitle());
        entity.setProfessionalImg(StrSplitUtils.list2string(params.getProfessionalImg()));
        entity.setBearThePalmImg(StrSplitUtils.list2string(params.getBearThePalmImg()));
        entity.setPatentImg(StrSplitUtils.list2string(params.getPatentImg()));
        entity.setPressNo(params.getPressNo());
        entity.setRegion(params.getRegion());
        entity.setSite(params.getSite());
        entity.setSignImg(StrSplitUtils.list2string(params.getSignImg()));
        entity.setProductPriceMin(params.getProductPriceMin());
        entity.setProductPriceMax(params.getProductPriceMax());
        entity.setAntiFake(params.getAntiFake());
        entity.setImages(StrSplitUtils.list2string(params.getImages()));
        entity.setAnnualSales(params.getAnnualSales());
        entity.setOnlineSalesName(params.getOnlineSalesName());
        entity.setOfflineSales(params.getOfflineSales());
        entity.setScale(params.getScale());
        tenantApplyInfoService.save(entity);
        return BaseResult.ok(entity);
    }

}
